package com.lz.football.module.ladderMatch.item
{
	import com.common.utils.DisplayObjectUtil;
	import com.common.utils.Reflection;
	import com.liangzhong.events.AppEventDispatcher;
	import com.liangzhong.events.FriendEvent;
	import com.liangzhong.model.AppData;
	import com.liangzhong.model.friend.vo.FriendInfoVo;
	import com.lz.football.module.base.IComponent;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.text.TextField;

	/**
	 *天梯报名ITEm
	 *  
	 * @author Administrator
	 * 
	 */	
	public class LadderApplyItem extends Sprite implements IBaseItem, IComponent
	{
		private  var _skin:MovieClip;
//		/**
//		 *队徽图标  
//		 */
//		private var icon:MovieClip;
		/**
		 *名称  
		 */
		private var playerName:TextField;
		/**
		 *等级 
		 */
		private var Lv:TextField;
		/**
		 * vip 
		 */
		private var vip:TextField;
		private var _data:*;
		public function LadderApplyItem()
		{
			super();
		}
		
		public function set data(value:*):void
		{
			_data = value;
//			DisplayObjectUtil.removeAllChildren(icon);
//			if(AppData.getInstance().clubDatamanager.getTeamIconVo(_data.logo) != null)
//			{
//				var lo:MovieClip = Reflection.createInstance(AppData.getInstance().clubDatamanager.getTeamIconVo(_data.logo).iconurl);
//				lo.scaleX = lo.scaleY = 0.2;
//				lo.x = -lo.width >> 1;
//				lo.y = -lo.height >> 1;
//			}
			
//			icon.addChild(lo);
			playerName.text = _data.clubname + "";
			vip.text = "";
			if(_data.VIP > 0)
			{
				vip.htmlText = "<font size = '16'>Vip<\font><font size = '20'>" + _data.VIP + "<\font>";
			}
			
			Lv.text = "Lv."+_data.level;
			addEvtListener();
		}
		
		public function get data():*
		{
			
			return _data;
		}
		
		
		public function initUI(view:Object=null):void
		{
			if(view is String)
			{
				_skin = Reflection.createInstance(view as String);
			}
			
			
			if(_skin == null)return;
			this.addChild(_skin);
			this.buttonMode = true;
//			icon = _skin.icon;
			playerName = _skin.playerName
			Lv = _skin.Lv;
			vip = _skin.vip;
//			icon.mouseChildren = false;
//			icon.mouseEnabled = false;
			playerName.mouseEnabled = false;
			Lv.mouseEnabled = false;
			vip.mouseEnabled = false;
		}
		/**
		 *重置 
		 * 
		 */
		private function reset():void
		{
//			DisplayObjectUtil.removeAllChildren(icon);
			
		}
		public function addEvtListener():void
		{
			this.addEventListener(MouseEvent.CLICK,onclickHandler);
		}
		/**
		 *查看信息 
		 * @param event
		 * 
		 */
		protected function onclickHandler(event:MouseEvent):void
		{
			if(data == null || data.clubid <=0)return;
			var f:FriendInfoVo = new FriendInfoVo();
			f.friendid = data.clubid;
			AppEventDispatcher.getInstance().dispatchEvent(new FriendEvent(FriendEvent.LOOK_UP_FRIEND,{vo:f}));
		}
		public function removeEvtListener():void
		{
			this.removeEventListener(MouseEvent.CLICK,onclickHandler);
		}
		
		public function destroyView():void
		{
			removeEvtListener();
			if(this.parent)this.parent.removeChild(this);
			_skin = null;
		}
		
	}
}